package gov.kqqzyyy.monkey.orderpad.mytools;

import java.util.concurrent.TimeUnit;

import gov.kqqzyyy.monkey.orderpad.R;
import gov.kqqzyyy.monkey.orderpad.service.BFXTService;
import gov.kqqzyyy.monkey.orderpad.service.OrderService;
import gov.kqqzyyy.monkey.orderpad.service.WXZFService;
import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.scalars.ScalarsConverterFactory;

/**
 * Created by Monkey on 2017/11/1.
 * Service工具类
 */
public class MyServiceUtil {

    private static final String baseUrl1 = MyApplication.applicationContext.getString(R.string.time_url);
    private static final String baseUrl2 = MyApplication.applicationContext.getString(R.string.default_url2);
    private static final String baseUrl3 = MyApplication.applicationContext.getString(R.string.default_url3);
    private static final OkHttpClient client = new OkHttpClient.Builder()
            .connectTimeout(20, TimeUnit.SECONDS)
            .readTimeout(20, TimeUnit.SECONDS)
            .writeTimeout(20, TimeUnit.SECONDS)
            .build();
    private static final Retrofit retrofit1 = new Retrofit.Builder()
            .baseUrl(baseUrl1)
            .client(client)
            .addConverterFactory(ScalarsConverterFactory.create())
            .build();
    private static final Retrofit retrofit2 = new Retrofit.Builder()
            .baseUrl(baseUrl2)
            .client(client)
            .addConverterFactory(ScalarsConverterFactory.create())
            .build();
    private static final Retrofit retrofit3 = new Retrofit.Builder()
            .baseUrl(baseUrl3)
            .client(client)
//            .addConverterFactory(GsonConverterFactory.create(new Gson()))
            .addConverterFactory(ScalarsConverterFactory.create())
            .build();

    private static final BFXTService bfxtService = retrofit1.create(BFXTService.class);
    private static final WXZFService wxzfService = retrofit2.create(WXZFService.class);
    private static final OrderService orderService = retrofit3.create(OrderService.class);

    public static Call<String> getDSXXCall(String mac) { //获取电视信息
        return bfxtService.getDSXX(mac);
    }

    public static Call<String> getSystemTimeCall() { //获取系统时间
        return bfxtService.getSystemTime();
    }

    public static Call<String> getPatientsCall(String mac) { //获取病房病人
        return bfxtService.getPatients(mac);
    }

    public static Call<String> getBFDZCall(String dspd) { //获取播放地址
        return bfxtService.getBFDZ(dspd);
    }

    public static Call<String> getYSLXCall() {
        return bfxtService.getYSLX();
    }

    public static Call<String> getYSXXCall(int lxid, String ysmc, int pageNum, int pageSize) {
        return bfxtService.getYSXX(lxid, ysmc, pageNum, pageSize);
    }

    public static Call<String> getYSBFDZCall(int ysid) {
        return bfxtService.getYSBFDZ(ysid);
    }

    public static Call<String> getTPXXCall(int pageIndex, int pageSize) {
        return bfxtService.getTPXX(pageIndex, pageSize);
    }

    public static Call<String> getFYXXCall(String zyh, int pageIndex, int pageSize) {
        return bfxtService.gerFYXX(zyh, pageIndex, pageSize);
    }

    public static Call<String> getWXURLCall(String productID, String total) {
        return wxzfService.getWXURL(productID, total);
    }

    public static Call<String> getPayInfoCall(String out_trade_no) {
        return wxzfService.getPayInfo(out_trade_no);
    }

    public static Call<String> saveJSJLCall(String brzyh, String dcddh, String shddh, String wxurl, String qqsj, String fkje) {
        return bfxtService.saveJSJL(brzyh, dcddh, shddh, wxurl, qqsj, fkje);
    }

    public static Call<String> saveJSJLLogCall(String brzyh, String dcddh, String jlsj, String fhjg) {
        return bfxtService.saveJSJLLog(brzyh, dcddh, jlsj, fhjg);
    }

    public static Call<String> saveFKXXCall(String dcddh, String fksj, String zfwxbz, String wxhgz) {
        return bfxtService.saveFKXX(dcddh, fksj, zfwxbz, wxhgz);
    }

//    public static Call<String> getCPXXCall(String dateTomorrow, int cc) {
//        return bfxtService.getCPXX(dateTomorrow, cc);
//    }

    public static Call<String> getMRCPCall(String dateTomorrow) {
        return bfxtService.getMRCP(dateTomorrow);
    }

    public static Call<String> saveDDXXCall(String CWH, String ZYH, String SCSJ, String XDSJ, String DDH, String SCLX, String SDCP, int DDZT, String ZJG, String SCBZ, String BRXM) {
        return bfxtService.saveDDXX(CWH, ZYH, SCSJ, XDSJ, DDH, SCLX, SDCP, DDZT, ZJG, SCBZ, BRXM);
    }

//    public static Call<String> getDDXXCall(String cwh, String xdsj) {
//        return bfxtService.getDDXX(cwh, xdsj);
//    }

    public static Call<String> getKWBZCall() {
        return bfxtService.getKWBZ();
    }

    public static Call<String> getPatientDCDDCall(String zyh) {
        return bfxtService.getPatientDCDD(zyh);
    }

    public static Call<String> cancelOrderCall(String dcddh, String tksj, String tkje, String tkdh, String tkfs) {
        return bfxtService.cancelOrder(dcddh, tksj, tkje, tkdh, tkfs);
    }

    public static Call<String> getRefundCall(String out_trade_no, String out_refund_no, String op_user_id, String total_fee, String refund_fee) {
        return wxzfService.getRefund(out_trade_no, out_refund_no, op_user_id, total_fee, refund_fee);
    }

    public static Call<String> getWeatherCall(String city) {
        return bfxtService.getWeather(city);
    }

    public static Call<String> getFloorsAndBedsCall(int buildNum) {
        return orderService.getFloorsAndBeds(buildNum);
    }

    public static Call<String> getFloorPatientsCall(int buildNum, String brbh) {
        return orderService.getFloorPatients(buildNum, brbh);
    }

    public static Call<String> getJRHCPatientCall() {
        return bfxtService.getHcxxes();
    }

    public static Call<String> saveDDXXLXCall(String jsonString) {
        return bfxtService.saveDDXX_LX(jsonString);
    }

    public static Call<String> doLoginCall(String bh,String ym) {
        return orderService.doLogin(bh, ym);
    }

}

